{extend name="public:base" /}

{block name="css"}
<link href="/static/laydate/theme/default/laydate.css">
{/block}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <!--<div class="ibox-title">
                    <h3>游客人数：{:levelCount(1)}人，VIP人数：{:levelCount(2)}人，社区服务站：{:levelCount(3)}人；县区服务站：{:levelCount(4)}人；城市服务站：{:levelCount(5)}人</h3>
                </div>-->


                <div class="ibox-content">
                    <div class="row search-form">
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <input placeholder="请输入会员昵称"  name="username" value="{:input('username')}" type="text" class="form-control form-control-lg">
                            </div>
                        </div>
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <input placeholder="请输入会员手机号" name="mobile" value="{:input('mobile')}" type="number" class="form-control form-control-lg">
                            </div>
                        </div>
                        <!--<div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <select class="form-control" name="level">
                                    <option value="0">请选择会员等级</option>
                                    <option value="1" {:input('level') == 1 ? 'selected' : ''}>游客</option>
                                    <option value="2" {:input('level') == 2 ? 'selected' : ''}>VIP</option>
                                    <option value="3" {:input('level') == 3 ? 'selected' : ''}>社区服务站</option>
                                    <option value="4" {:input('level') == 4 ? 'selected' : ''}>县区服务站</option>
                                    <option value="5" {:input('level') == 5 ? 'selected' : ''}>城市服务站</option>
                                </select>
                            </div>
                        </div>-->
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <input placeholder="请选择开始日期" type="text" name="start_time" value="{:input('start_time')}" class="form-control form-control-lg screen-date" readonly>
                            </div>
                        </div>
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <input placeholder="请选择结束日期" type="text" name="end_time" value="{:input('end_time')}" class="form-control form-control-lg screen-date" readonly>
                            </div>
                        </div>
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <button type="button" class="btn btn-primary btn-lg screen-btn">搜索</button>
                            </div>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th width="4%">ID</th>
                                <th width="9%">会员昵称</th>
                                <th width="8%">联系方式</th>
<!--                                <th width="12%">所在区域</th>-->
<!--                                <th width="7%">等级</th>-->
<!--                                <th width="6%">消费金额</th>-->
<!--                                <th width="6%">可用收益</th>-->
<!--                                <th width="6%">冻结收益</th>-->
<!--                                <th width="5%">分享数</th>-->
<!--                                <th width="9%">推荐人</th>-->
                                <th width="5%">状态</th>
                                <th width="7%">创建时间</th>
                                <th width="16%">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="list" id="vo"}
                            <tr>
                                <td>{$vo.id}</td>
                                <td>{$vo.username}</td>
                                <td>{$vo.mobile}</td>
<!--                                <td>{$vo.address}</td>-->
<!--                                <td>{$vo.level_txt}</td>-->
<!--                                <td>{$vo.all_consume}</td>-->
                                <!--<td>
                                    <a href="{:url('userProfitList', ['id' => $vo.id])}">{$vo.all_profit}</a>
                                </td>-->
<!--                                <td>{$vo.frozen_profit}</td>-->
<!--                                <td>{$vo.share_count}</td>-->
<!--                                <td>{$vo.up_username}</td>-->
                                <td>{$vo.status_txt}</td>
                                <td>{:timeFormat($vo.create_time, "Y-m-d")}</td>
                                <td class="project-actions">
                                    {if condition="$vo['status'] != 1"}
                                    <a href="{:url('statusUser', ['id' => $vo.id,'status'=>1])}" class="btn btn-white btn-sm ajax-operate" data-msg="确定要修改吗？">
                                        <i class="fa fa-check"></i> 正常
                                    </a>
                                    {/if}
                                    {if condition="$vo['status'] != 2"}
                                    <a href="{:url('statusUser', ['id' => $vo.id,'status'=>2])}" class="btn btn-white btn-sm ajax-operate" data-msg="确定要禁用吗？">
                                        <i class="fa fa-close"></i> 禁用
                                    </a>
                                    {/if}
                                    {if condition="$vo['status'] != 3"}
                                    <a href="{:url('statusUser', ['id' => $vo.id,'status'=>3])}" class="btn btn-white btn-sm ajax-operate" data-msg="确定要激活吗？">
                                        <i class="fa fa-check"></i> 激活
                                    </a>
                                    {/if}
                                    <!--<a href="{:url('shareUserList', ['user_id' => $vo.id])}" class="btn btn-white btn-sm">
                                        <i class="fa fa-list"></i> 推广用户
                                    </a>
                                    <a href="javascript: void(0)" onclick="addModelOpenProfit({$vo.id})" class="btn btn-white btn-sm">
                                        <i class="fa fa-arrows-v"></i> 收益变更
                                    </a>
                                    <a href="javascript: void(0)" onclick="addModelOpenLevel({$vo.id}, {$vo.level})" class="btn btn-white btn-sm">
                                        <i class="fa fa-arrows-v"></i> 级别变更
                                    </a>
                                    <a href="{:url('profitSummaryList', ['user_id' => $vo.id])}" class="btn btn-white btn-sm">
                                        <i class="fa fa-list"></i> 收益汇总
                                    </a>-->
                                    <a href="{:url('doUser', ['id' => $vo.id])}" class="btn btn-white btn-sm">
                                        <i class="fa fa-edit"></i> 详情
                                    </a>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                        {if !empty($list->items())}{$list->render()}{/if}
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<!--  收益变更弹出框  -->
<div class="modal inmodal" id="myModal3" tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content animated flipInY">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" onclick="modelCloseProfit()"><span
                        aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">收益变更</h4>
            </div>
            <div class="modal-body">
                <select class="form-control type">
                    <option value="0">请选择变更类型</option>
                    <option value="1">充值收益</option>
                    <option value="2">处罚收益</option>
                </select>

                <input type="number" class="form-control price" min="0" placeholder="请输入变更数额" style="margin-top: 10px">

                <input type="text" class="form-control reason" maxlength="25" placeholder="请输入变更原因" style="margin-top: 10px">

                <input type="hidden" class="id" value="">
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-white" onclick="modelCloseProfit()">关闭</button>
                <button type="button" class="btn btn-primary" onclick="confirmProfitChange()">确认</button>
            </div>
        </div>
    </div>
</div>

<!--  级别变更弹出框  -->
<div class="modal inmodal" id="myModal4" tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content animated flipInY">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" onclick="modelCloseLevel()"><span
                        aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">级别变更</h4>
            </div>
            <div class="modal-body">
                <select class="form-control level">
                    <option value="1">游客</option>
                    <option value="2">VIP</option>
                    <option value="3">社区服务站</option>
                    <option value="4">县区服务站</option>
                    <option value="5">城市服务站</option>
                </select>

                <input type="text" class="form-control reason" maxlength="25" placeholder="请输入变更原因" style="margin-top: 10px">

                <input type="hidden" class="id" value="">
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-white" onclick="modelCloseLevel()">关闭</button>
                <button type="button" class="btn btn-primary" onclick="confirmLevelChange()">确认</button>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<script src="/static/laydate/laydate.js"></script>
<script>
    laydate.render({
        elem: '.screen-date' //指定元素
    });

    // 打开 收益变更 弹框
    function addModelOpenProfit(id) {
        $('body').addClass('modal-open').append('<div class="modal-backdrop show"></div>');
        $('#myModal3').css('display', 'block').addClass('show');

        $('.id').val(id);
    }

    // 关闭 收益变更 弹框
    function modelCloseProfit() {
        $('body').removeClass('modal-open');
        $('.modal-backdrop').remove();
        $('#myModal3').css('display', 'none').removeClass('show');

        $('.type').val(0);
        $('.price').val('');
        $('.reason').val('');
        $('.id').val('');
    }

    // 收益变更
    var clickCount = 0;
    function confirmProfitChange() {
        var id = $('.id').val();
        var type = $('.type').val();
        var price = $('.price').val();
        var reason = $('.reason').val();
        if(clickCount == 0){
            ++clickCount;
            $.post("{:url('profitChange')}", {
                id: id,
                type: type,
                price: price,
                reason: reason
            }, function (res) {
                if (res.result == 1) {
                    layer.msg(res.msg);
                    setTimeout(function () {
                        window.location.reload();
                    }, 500)
                } else {
                    clickCount = 0;
                    layer.msg(res.msg);
                }
            }, 'json')
        }
    }

    /***************************************** 分界线 *****************************************/

    // 打开 级别变更 弹框
    function addModelOpenLevel(id, level) {
        $('body').addClass('modal-open').append('<div class="modal-backdrop show"></div>');
        $('#myModal4').css('display', 'block').addClass('show');

        $('#myModal4 .level').val(level);
        $('#myModal4 .id').val(id);
    }

    // 关闭 级别变更 弹框
    function modelCloseLevel() {
        $('body').removeClass('modal-open');
        $('.modal-backdrop').remove();
        $('#myModal4').css('display', 'none').removeClass('show');

        $('#myModal4 .reason').val('');
        $('#myModal4 .id').val('');
    }

    // 级别变更
    function confirmLevelChange() {
        var id = $('#myModal4 .id').val();
        var level = $('#myModal4 .level').val();
        var reason = $('#myModal4 .reason').val();

        $.post("{:url('levelChange')}", {
            id: id,
            level: level,
            reason: reason
        }, function (res) {
            if (res.result == 1) {
                layer.msg(res.msg);
                setTimeout(function () {
                    window.location.reload();
                }, 500)
            } else {
                layer.msg(res.msg);
            }
        }, 'json')
    }
</script>
{/block}

